package weekone;

import java.util.Stack;

public class MinStack_155 {

    Stack<Integer> stack = new Stack<>();
    Stack<Integer> minStack = new Stack<>();

    /** initialize your data structure here. */
    public MinStack_155() {

    }

    public void push(int val) {
        stack.push(val);
        minStack.push(minStack.isEmpty()? val :Math.min(val, (int)minStack.peek()));

    }

    public void pop() {
        stack.pop();
        minStack.pop();
    }

    public int top() {
        return stack.peek();
    }

    public int getMin() {
        return minStack.peek();
    }
}
